package com.hzxcloudserviceb.service.impl;

import com.hzxcloudserviceb.message.MessageData;
import com.hzxcloudserviceb.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by huzuxing on 2021/4/29.
 */
@Service("messageService")
public class MessageServiceImpl implements MessageService{
    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;
    @Override
    public void send(Object msg) {
        MessageData messageData = new MessageData();
        messageData.setId(1);
        messageData.setName(String.valueOf(msg));
        messageData.setSendTime(new Date());
        kafkaTemplate.send("wqh", messageData.toString());
    }

    @Override
    public void consume() {

    }

}
